package net.xt.myupload.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("classpath: /static/");

        // 文件上传的windows系统本地文件目录
        registry.addResourceHandler("/upload/**").addResourceLocations("file: D:/upload/");
    }


    // 配置异步方法调用时候的超时时间
    @Override
    public void configureAsyncSupport(AsyncSupportConfigurer configurer) {
        // -1 为不超时。可以根据项目自己设置毫秒值
        // springboot默认是30秒
        configurer.setDefaultTimeout(-1);
    }
}
